<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="assets/images/favicon.png" type="image/png">
    <title></title>
    <link href="assets/css/icons.css" rel="stylesheet">
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/responsive.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->

</head>

<body>


<!--Start login Section-->
<section class="login-section">
    <div class="container">
        <div class="row">
            <div class="login-wrapper">
                <div class="login-inner">

                    <div class="logo">
                        <img src="assets/images/logo-dark.png" alt="logo"/>
                    </div>

                    <h2 class="header-title text-center">Sign Up</h2>

                    <form>
                        <div class="form-group">
                            <input type="text" id="sellerName" class="form-control" placeholder="sellerName">
                        </div>

                        <div class="form-group">
                            <input type="text" id="password" class="form-control" placeholder="password">
                        </div>

                        <div class="form-group">
                            <input type="text" id="phone" class="form-control" placeholder="phone">
                        </div>

                        <div class="form-group">
                            <div class="pull-left">
                                <div class="checkbox primary">
                                    <input id="checkbox-1" type="checkbox">
                                    <label for="checkbox-1">I accept <a href="#">Terms and Conditions</a></label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <input type="submit" onclick="return  registration(false)" value="注册"
                                   class="btn btn-primary btn-block">
                        </div>

                        <div class="form-group text-center">
                            Already have an account? <a href="login.html">Sign In </a>
                        </div>

                    </form>

                    <form  id= "uploadForm" >
                        <input type="file" name="file" id="fileUpload"/>
                        <input type="button" onclick=" doUpload()" value="上传"/>
                    </form>

                    <div class="copy-text">
                        <p class="m-0">2017 &copy; Meter admin</p>
                    </div>

                </div>
            </div>

        </div>
    </div>
</section>
<!--End login Section-->


<!--Begin core plugin -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/plugins/moment/moment.js"></script>
<script src="assets/js/jquery.slimscroll.js "></script>
<script src="assets/js/jquery.nicescroll.js"></script>
<script src="assets/js/functions.js"></script>
<script src="assets/js/util/http-util.js"></script>
<!-- End core plugin -->


</body>

<script>
    function registration() {
        console.log("前端请求开始");
        let sellerName = $("#sellerName").val();
        let password = $("#password").val();
        let phone = $("#phone").val();
        if (sellerName === "") {
            alert("名字不能为空");
            return;
        }
        if (password === "") {
            alert("密码不能为空");
            return;
        }
        if (phone === "") {
            alert("电话不能为空");
            return;
        }
        let parm = {sellerName: sellerName, password: password, phone: phone};
        console.log("发起ajax");
        let url = "/shop_admin/registration";
        doPost(url, parm, function () {
            alert("注册成功，请登录");
            location.href = "/view_admin/login.html";
        });
        return false;
    }


    function doUpload() {
        var formData = new FormData($( "#uploadForm" )[0]);
        $.ajax({
            url: 'http://localhost:8080/shop_admin/upload' ,
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (returndata) {
                var parse = JSON.parse(returndata);
                if (parse.code===100){
                    alert("上传成功");
                }
                else {
                    alert(parse.msg);
                }
            },
            error: function (returndata) {
                alert(returndata.msg);
            }
        });
    }
</script>
</html>
